#pragma once

#include "fxcc/core/graph/common/Transform.h"
#include "fxcc/core/graph/common/Animation.h"

namespace fxcc
{
    namespace graph
    {
        namespace common
        {

            struct FXCC_API     ChannelDataSet
            {
                struct FXCC_API     DataMap
                {
                    fxcc::graph::common::Transform m_LocalTransform;
                    std::string m_Name;
                };

                std::map<std::string, DataMap> m_ChannalDataMaps;

                bool HasBone(const std::string& name) const
                {
                    auto it = m_ChannalDataMaps.find(name);
                    return it != m_ChannalDataMaps.end();
                }
                ChannelDataSet(std::vector<fxcc::graph::common::Animation *> anims)
                {

                    for (auto anim : anims)
                    {
                        ztclog::debug("channel data set Load %s", anim->m_Name.c_str());
                        for (auto it : anim->m_Channels)
                        {
                            auto name = it.first;
                            auto &dataMap = m_ChannalDataMaps[name];
                            dataMap.m_Name = name;
                        }
                    }
                };
                void LoadAnimation(const fxcc::graph::common::Animation &anim, const float axis)
                {
                    for (auto it : m_ChannalDataMaps)
                    {
                        auto name = it.first;
                        auto &dataMap = m_ChannalDataMaps[name];
                        dataMap.m_LocalTransform = anim.GetChannelTransform(name, axis);
                    }
                };
                void LoadAnimation(const fxcc::graph::common::Animation& anim1,
                                   const float axis1,
                                   const fxcc::graph::common::Animation & anim2,
                                   const float axis2,
                                   const float axis3)
                {

                    for (auto it : m_ChannalDataMaps)
                    {
                        auto name = it.first;
                        auto transform1 = anim1.GetChannelTransform(name, axis1);
                        auto transform2 = anim2.GetChannelTransform(name, axis2);

                        auto transformResult = fxcc::graph::common::Transform::Slerp(transform1, transform2, axis3);

                        auto &dataMap = m_ChannalDataMaps[name];
                        dataMap.m_LocalTransform = transformResult;
                    }
                };
            };
        };
    };
};